package JDBC;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;


public class Eleve_Supprimer {
	
	public  void supprimer(int id) {
		
		try {
			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			Statement state = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
			Statement state2 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
			Statement state3 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
			//Statement state4 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
			//Statement state5 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
			
				ResultSet result = state.executeQuery("SELECT id_lieu_cours, id_famille FROM eleve WHERE id_eleve ="+id);
				
				/*int id_adresse=0;
				while(result.next()){	
					id_adresse = Integer.parseInt(result.getObject(1).toString());
				}
				
				int id_famille=0;
				while(result.next()){	
					id_famille = Integer.parseInt(result.getObject(2).toString());
				}*/
				
				state.close();
				result.close();
				
				state3.executeUpdate("DELETE FROM cours WHERE id_eleve = "+id);
				state2.executeUpdate("DELETE FROM eleve WHERE id_eleve = "+id);
				//state4.executeUpdate("DELETE FROM famille WHERE id_famille = "+id_famille);
				//state5.executeUpdate("DELETE FROM lieu WHERE id_lieu = "+id_adresse);
				
				state2.close();
				state3.close();
				//state4.close();
				//state4.close();
		} 
		catch (Exception e) {
			e.printStackTrace();
		}	

	}

}
